/**
 * Created with JetBrains WebStorm.
 * User: Chacha
 * Date: 12/06/13
 * Time: 13:40
 * To change this template use File | Settings | File Templates.
 */

var Arroser = function(type){

    Action.call(this);

    this.name="Arroser";
    if (type == undefined || type == "tile")
        type = "tile";
    this.type = type;
    this.waterImage = new Image();
    this.waterImage.src = "/images/arrosoir_50.png";


}

Arroser.prototype = {

    canDo : function(tile,personage){

        if (this.type == "plant")
            tile = tile.tile;
        if (this.distanceReq(tile,personage,300)){
            if(this.checkOwnership(tile,personage)){
                //if(!this.checkFreeTile(tile)){


                    //batiment
                    return true;
                //}
            }

        }
        return false;


    },
    //To draw the button as you wish
    drawButton : function(ctx,worldInterface,actionButton){

        ctx.drawImage(
            this.waterImage,
            actionButton.x, actionButton.y, actionButton.width, actionButton.heigh);
        worldInterface.showFillText(ctx,this.name,
            actionButton.x + actionButton.width/2, actionButton.y - 10,"#7EDAEF","15pt Calibri","","center");
    },

    do : function(tile,worldInterface){

        if (this.type == 'tile'){
            tile.humidity += 20;
            if (tile.humidity > 100)
                tile.humidity = 100;
        }
        if (this.type == "plant"){

            tile.tile.humidity += 20;
            if (tile.tile.humidity > 100)
                tile.tile.humidity = 100;
        }

    }
}